
cmake_minimum_required(VERSION 3.10)

project(libA)

add_library(libA STATIC libA.cpp)
set_target_properties(libA PROPERTIES DEBUG_POSTFIX "d")

target_include_directories(libA PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
        $<INSTALL_INTERFACE:${ModulesDir}/include>
)

#file(GLOB_RECURSE LibA_Headers ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp)
#message(STATUS "LibA_Headers:${LibA_Headers}")
#set_target_properties(libA PROPERTIES PUBLIC_HEADER "${LibA_Headers}")

install(TARGETS libA
        EXPORT ${ModulesName} # 设置对应的module，module 导出的配置文件会包含当前库的配置信息
        LIBRARY DESTINATION "${ModulesDir}/lib"
        ARCHIVE DESTINATION "${ModulesDir}/lib"
        RUNTIME DESTINATION "${ModulesDir}/bin"
#        PUBLIC_HEADER DESTINATION "${ModulesDir}/include" # 不能保证目录结构
        COMPONENT libA
)

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
        DESTINATION "${ModulesDir}/include"
        COMPONENT libA
#        EXCLUDE_FROM_ALL # 只能通过install指定 --component libA 安装
        FILES_MATCHING
        PATTERN "*.hpp"
        PATTERN "*.h"
        PATTERN "*.cpp" EXCLUDE
#       REGEX "(.hpp)|(.h)$" #使用正则表达式匹配
)